package com.dgw.springbootautoconfig2;

import com.kk.hellospringbootstarter.config.PersonProperties;
import com.kk.hellospringbootstarter.config.PersonService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.core.annotation.Order;

@SpringBootApplication
public class Springbootautoconfig2Application {

    @Bean("user")
    @Order(0)
    public User gerBean(){
        return new User();
    }

    class User{
        private String username;
    }
    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(Springbootautoconfig2Application.class, args);

        String [] names = context.getBeanDefinitionNames();
        for (String s : names) {
            System.out.println(s);
        }

        /*Object personService = context.getBean("personService");
        PersonService p=personService instanceof PersonService ? ((PersonService) personService) : null;
        if (p != null) {
            p.sayHello();
        }*/

        context.getBean("user");

    }

}
